package org.example.medical.service.impl;

import org.example.medical.Mapper.AdmissionRecordMapper;
import org.example.medical.entity.AdmissionRecord;
import org.example.medical.service.AdmissionRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdmissionRecordServiceImpl implements AdmissionRecordService {
    @Autowired
    private AdmissionRecordMapper admissionRecordMapper;
    @Override
    public List<AdmissionRecord> getAdmissionRecords(String patientName, String admissionDate, String dischargeDate, int page, int size) {
        int offset = (page - 1) * size;
        return admissionRecordMapper.selectByPageAndFilters(
                patientName,
                admissionDate,
                dischargeDate,
                offset,
                size
        );
    }

    @Override
    public void addAdmissionRecord(AdmissionRecord admissionRecord) {
        admissionRecordMapper.insertAdmissionRecord(admissionRecord);

    }

    @Override
    public void updateAdmissionRecord(AdmissionRecord admissionRecord) {
        admissionRecordMapper.updateAdmissionRecord(admissionRecord);

    }

    @Override
    public void softDeleteAdmissionRecord(Long recordId) {
        admissionRecordMapper.softDeleteAdmissionRecord(recordId);

    }

    @Override
    public void batchSoftDeleteAdmissionRecords(List<Long> recordIds) {
        admissionRecordMapper.batchSoftDeleteAdmissionRecords(recordIds);

    }
}
